<input type="hidden" value="${ctx}" id="basePath">

<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>试题修改</title>

    <link href="${ctx}/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/animate.min.css" rel="stylesheet">
    <link href="${ctx}/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <!--单选框样式-->
    <link href="${ctx}/css/labelauty.css" rel="stylesheet"/>

    <script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctx}/js/content.min.js?v=1.0.0"></script>
    <script src="${ctx}/js/plugins/layer/layer.js"></script>
    <script src="${ctx}/js/exam/exam-update.js"></script>
    <#--表单验证-->
    <link href="${ctx}/parsley/parsley.css" rel="stylesheet">
    <script src="${ctx}/parsley/parsley.min.js"></script>
    <style type="text/css">
        .check-image {
            background: url(${ctx}/images/input-unchecked.png) no-repeat;
        }
        /**********************************自定义单选框样式******************************************/
        .rdo {
            height: 34px;
            border: 1px solid #e5e6e7;
        }

        .rdobox {
            border-radius: 0;
            height: 34px;
        }

        /**********************************自定义单选框样式******************************************/

        label {
            margin-bottom: 0px;
        }

        .waring {
            position: fixed;
            top: 18%;
            right: 12%;
            min-height: 80px;
            width: 15%;
        }

        /*去圆角*/
        .nav-tabs li a {
            border-radius: 0 0 0 0;
        }
    </style>
</head>
<body class="gray-bg" onload="getTime(),loadAnswer('#answer-content-wenda-fsen')">
<br>
<div class="wrapper wrapper-content animated fadeInUp waring">
    <ul class="notes">
        <li>
            <div style="transform:rotate(0deg);">
                <small id="date-time" style="text-align: left;width: 92%"></small>
                <br>
                <h4>温馨提示</h4>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>试题题干不可与已存在的试题题干相同，系统将会对此进行验证。</p>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>需要增加定位、主治或者答案项时，请点击添加按钮。</p>
                <p><span class="glyphicon glyphicon-triangle-right" style="color: limegreen" ></span>需要减少答案或者主治项时，请点击“叉号”进行删除。</p>
            </div>
        </li>
    </ul>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="tabbable" id="tabs-576364">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#panel-1" data-toggle="tab">问答题</a></li>
                    <li><a >穴位定位</a></li>
                    <li><a>单项手法</a></li>
                    <li><a>成套手法</a></li>
                </ul>
                <br/>
                <div class="tab-content">
                    <div class="tab-pane active" id="panel-1">
                        <form class="form-horizontal" id="table-example">
                            <div class="col-md-9">
                                <input type="hidden" value="${exam.id}" name="id"/>
                                <!--试题分类-->
                                <div class="form-group">
                                    <label class="col-md-2 control-label">分类</label>
                                    <div class="col-md-9">
                                        <div class="rdo">
                                            <!--腧穴题-->
                                            <input type="radio" name="categoryId" class="rdolist" value="1" />
                                            <label class="rdobox" radio-exam-category-val="1" id="radio-exam-acupoint">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">腧穴</span>
                                            </label>
                                            <!--内科-->
                                            <input type="radio" name="categoryId" class="rdolist" value="2" />
                                            <label class="rdobox" radio-exam-category-val="2" id="radio-exam-nk">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">内科</span>
                                            </label>
                                            <!--伤科-->
                                            <input type="radio" name="categoryId" class="rdolist" value="3"/>
                                            <label class="rdobox" radio-exam-category-val="3" id="radio-exam-sk">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">伤科</span>
                                            </label>
                                            <!--妇科-->
                                            <input type="radio" name="categoryId" class="rdolist" value="4"/>
                                            <label class="rdobox" radio-exam-category-val="4" id="radio-exam-fk">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">妇科</span>
                                            </label>
                                            <!--儿科-->
                                            <input type="radio" name="categoryId" class="rdolist" value="5"/>
                                            <label class="rdobox" radio-exam-category-val="5" id="radio-exam-ek">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">儿科</span>
                                            </label>
                                            <!--触诊-->
                                            <input type="radio" name="categoryId" class="rdolist" value="6"/>
                                            <label class="rdobox" radio-exam-category-val="6" id="radio-exam-cz">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">触诊</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            <#include "common.ftl">

                                <!--问答题答案模板-->
                                <div class="form-group "><label class="col-sm-2 control-label">答案</label>
                                    <div class="col-sm-6">
                                        <input type="text" class="form-control" name="answer1" value="${exam.answer1}"
                                               parsley-trigger="change" required maxlength="250" data-parsley-maxlength="250"/>
                                    </div>
                                    <label class="col-sm-1 control-label">分值</label>
                                    <div class="col-sm-2">
                                        <input type="text" class="form-control" name="answer1Score" value="${exam.answer1Score}"
                                               parsley-trigger="change" required data-parsley-range="[0,${examParamWendaFSENC.maxAnswerScore}]"/>
                                    </div>
                                    <div class="col-sm-1">
                                        <button class="btn  btn-primary" type="button" onclick="addTerms('#answer-content-wenda-fsen',9,'答案项已达上限')">
                                            <i class="glyphicon glyphicon-plus"></i>&nbsp;添加
                                        </button>
                                    </div>
                                </div>
                                <div id="answer-content-wenda-fsen"></div>
                                <div class="form-group">
                                    <div class="col-md-6" style="text-align: center;">
                                        <button type="button" onclick="submitForm()" class="btn btn-primary" style="background-color: #008200; color: white;">提交</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" value="<#if exam.answer2 ??>${exam.answer2}</#if>" id="answer2">
<input type="hidden" value="<#if exam.answer2Score ??>${exam.answer2Score}</#if>" id="answer2Score">
<input type="hidden" value="<#if exam.answer3 ??>${exam.answer3}</#if>" id="answer3">
<input type="hidden" value="<#if exam.answer3Score ??>${exam.answer3Score}</#if>" id="answer3Score">
<input type="hidden" value="<#if exam.answer4 ??>${exam.answer4}</#if>" id="answer4">
<input type="hidden" value="<#if exam.answer4Score ??>${exam.answer4Score}</#if>" id="answer4Score">
<input type="hidden" value="<#if exam.answer5 ??>${exam.answer5}</#if>" id="answer5">
<input type="hidden" value="<#if exam.answer5Score ??>${exam.answer5Score}</#if>" id="answer5Score">
<input type="hidden" value="<#if exam.answer6 ??>${exam.answer6}</#if>" id="answer6">
<input type="hidden" value="<#if exam.answer6Score ??>${exam.answer6Score}</#if>" id="answer6Score">
<input type="hidden" value="<#if exam.answer7 ??>${exam.answer7}</#if>" id="answer7">
<input type="hidden" value="<#if exam.answer7Score ??>${exam.answer7Score}</#if>" id="answer7Score">
<input type="hidden" value="<#if exam.answer8 ??>${exam.answer8}</#if>" id="answer8">
<input type="hidden" value="<#if exam.answer8Score ??>${exam.answer8Score}</#if>" id="answer8Score">
<input type="hidden" value="<#if exam.answer9 ??>${exam.answer9}</#if>" id="answer9">
<input type="hidden" value="<#if exam.answer9Score ??>${exam.answer9Score}</#if>" id="answer9Score">
<input type="hidden" value="<#if exam.answer10 ??>${exam.answer10}</#if>" id="answer10">
<input type="hidden" value="<#if exam.answer10Score ??>${exam.answer10Score}</#if>" id="answer10Score">
</body>

<script type="text/javascript">
    function submitForm() {
        if (!$('#table-example').parsley().validate()) {
            return;
        }
        var totalScore=getTotalScoreWendaNSFEC();
        $("#total-score").val(totalScore)
        if (totalScore>'${examParamWendaFSENC.maxTotalScore}') {
            layer.alert('总分超过上限，请修改!', {
                closeBtn: 0
            });
            return;
        }
        var url = '${ctx}/exam/examManage/update/examWendaFSENC';
        $.ajax({
            type: "POST",
            dataType: "JSON",
            url: url,
            data: $('#table-example').serialize(),
            success: function (data) {
                if (data.code == 0) {
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 4000
                    });
                }else{
                    layer.alert(data.msg, {
                        closeBtn: 0
                    });
                }
            },
            error: function(data) {
                layer.alert(data.msg, {
                    closeBtn: 0
                });
            }
        });
    }

    function  getTotalScoreWendaNSFEC() {
        var answer1Score=$("#table-example").find("input[name='answer1Score']").val();
        var total=0.0;
        total = parseFloat(total) +parseFloat(answer1Score);
        $("input[name='answerScore']").each(function(i){
            total=parseFloat($(this).val())+total;
        });
        return total;
    }

    var validateAnswerText = "parsley-trigger='change' required maxlength='250' data-parsley-maxlength='250' ";
    var validateAnswerScoreText = "parsley-trigger='change' required data-parsley-range='[0,${examParamWendaFSENC.maxAnswerScore}]'"

    function  loadAnswer(divId1) {
        var content;
        var answer2= $("#answer2").val() ;
        var answer2Score=$("#answer2Score").val();
        var answer3= $("#answer3").val() ;
        var answer3Score=$("#answer3Score").val();
        var answer4= $("#answer4").val() ;
        var answer4Score=$("#answer4Score").val();
        var answer5= $("#answer5").val() ;
        var answer5Score=$("#answer5Score").val();
        var answer6= $("#answer6").val() ;
        var answer6Score=$("#answer6Score").val();
        var answer7= $("#answer7").val() ;
        var answer7Score=$("#answer7Score").val();
        var answer8= $("#answer8").val() ;
        var answer8Score=$("#answer8Score").val();
        var answer9= $("#answer9").val() ;
        var answer9Score=$("#answer9Score").val();
        var answer10= $("#answer10").val() ;
        var answer10Score=$("#answer10Score").val();
        /*初始化定位答案*/
        if (answer2 != '' && answer2Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text'  "+validateAnswerText+" class='form-control' name='answer' value='"+answer2+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer2Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer3 != '' && answer3Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer3+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer3Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer4 != '' && answer4Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer4+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer4Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer5 != '' && answer5Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer5+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer5Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer6 != '' && answer6Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer6+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer6Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer7 != '' && answer7Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer7+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer7Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer8 != '' && answer8Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer8+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer8Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer9 != '' && answer9Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer9+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer9Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
        if (answer10 != '' && answer10Score != '') {
            wendaNSFECCount++;
            content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer' value='"+answer10+"' /></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'  value='"+answer10Score+"'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId1).append(content);
        }
    }

    function addTerms(divId,count,msg) {
        if (wendaNSFECCount > count) {
            // 询问框
            layer.confirm(msg, {
                btn: ["确认"]
                // 按钮
            });
        } else {
            wendaNSFECCount = wendaNSFECCount + 1;
            var content = "<div class='form-group'><div class='col-sm-2'></div><div class='col-sm-6'><input type='text' "+validateAnswerText+"  class='form-control' name='answer'placeholder='请输入答案......'/></div><label class='col-sm-1 control-label' style='padding-left:10px'>分值</label><div class='col-sm-2'><input type='text' "+validateAnswerScoreText+"  class='form-control' name='answerScore'/></div><div class='col-md-1'><i onclick='deleteNewAdd(this,\"wendaNSFECCount\")' class='glyphicon glyphicon-remove' style='margin-left: 80%;margin-top:12%;cursor: pointer;'></i></div></div>";
            $(divId).append(content);
        }
    }
    $(document).ready(function () {
        var categoryId=${exam.categoryId};
        if (categoryId ==1) {
            $("#radio-exam-acupoint").removeClass("unchecked");
            $("#radio-exam-acupoint").addClass("checked");
            $("#radio-exam-acupoint").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }else if (categoryId == 2) {
            $("#radio-exam-nk").removeClass("unchecked");
            $("#radio-exam-nk").addClass("checked");
            $("#radio-exam-nk").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }else if (categoryId == 3) {
            $("#radio-exam-sk").removeClass("unchecked");
            $("#radio-exam-sk").addClass("checked");
            $("#radio-exam-sk").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }else if (categoryId == 4) {
            $("#radio-exam-fk").removeClass("unchecked");
            $("#radio-exam-fk").addClass("checked");
            $("#radio-exam-fk").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }else if (categoryId == 5) {
            $("#radio-exam-ek").removeClass("unchecked");
            $("#radio-exam-ek").addClass("checked");
            $("#radio-exam-ek").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }else if (categoryId == 6) {
            $("#radio-exam-cz").removeClass("unchecked");
            $("#radio-exam-cz").addClass("checked");
            $("#radio-exam-cz").find(".check-image").css("background", "url(" + basePath + "/images/input-checked.png)");
        }
    });
</script>
</html>
